Ext.define('PJ.view.evaluationprogressbw.List', {
    extend: 'AM.default.DefaultList',
    requires: ['AM.default.DefaultSearchForm', 
               'AM.default.DateTime', 
               'AM.default.DefaultDateField'
               ],
     selModel: {
         selType: '',
         // 设置为只能通过复选框选中行
         checkOnly: true 
     },
    initComponent: function(){
    	var me = this;
        me.columns = [{
            header: '培训班编号',
            dataIndex: 'classNum',
            width: 70,
            sortable: false,
			renderer: function(value, metaData, record){
				metaData.tdAttr = 'data-qtip="' + value + '"';
				return value;
			}
        }, {
            header: '培训班问卷名称',
            dataIndex: 'className',
            flex: 1,
            minWidth: 120,
            sortable: false,
			renderer: function(value, metaData, record){
				metaData.tdAttr = 'data-qtip="' + value + '"';
				return value;
			}
        }, {
            header: '承办部委',
            dataIndex: 'ministrieName',
            width: 120,
            sortable: false,
			renderer: function(value, metaData, record){
				metaData.tdAttr = 'data-qtip="' + value + '"';
				return value;
			}
        }, {
            header: '开班时间',
            dataIndex: 'beginDate',
            width: 90,
            sortable: false,
            renderer: function(value, metaData, record){
                return value;
            }
        }, {
            header: '结业时间',
            dataIndex: 'endDate',
            width: 90,
            sortable: false,
            renderer: function(value, metaData, record){
                return value;
            }
        }, {
            header: '已报人数/计划人数',
            dataIndex: 'planCount',
            width: 130,
            sortable: false,
            renderer: function(value, metaData, record){
            	var reportedNum = record.get('reportedNum');
            	return reportedNum + "/" + value;
            }
        }, {
            header: '评估开始时间',
            dataIndex: 'assessStartTime',
            width: 100,
            sortable: false,
            renderer: function(value, metaData, record){
                return value;
            }
        }, {
            header: '评估结束时间',
            dataIndex: 'assessEndTime',
            width: 100,
            sortable: false,
            renderer: function(value, metaData, record){
                return value;
            }
        }, {
            header: '已评估人数',
            dataIndex: 'answerUser',
            width: 80,
            sortable: false,
            renderer: function(value, meta, record){
                meta.style = "overflow: hidden;text-overflow: ellipsis;";
                meta.tdAttr = 'data-qtip="' + value + '" paperID=' + record.get("classId") + ' questionnaireId="' + record.get("questionnaireId") + '"';
                return value;
            }
        }, {
            header: '未评估人数',
            dataIndex: 'noAnswerUser',
            width: 80,
            sortable: false,
            renderer: function(value, meta, record){
                meta.style = "overflow: hidden;text-overflow: ellipsis;";
                meta.tdAttr = 'data-qtip="' + value + '" paperID=' + record.get("classId") + ' questionnaireId="' + record.get("questionnaireId") + '"';
                return value;
            }
        },{
            header: '参评率（%）',
            dataIndex: 'nswerPerc',
            width: 90,
            sortable: false,
            renderer: function(value, meta, record){
            	meta.tdAttr = "data-qtip='" + value + "'";
            	return value;
            }
        }];
        me.store = Ext.create('PJ.'+ prototype +'.evaluationprogressbw.List', {
            isLoad: false
        });
        this.loadType = gj_onlineLearning_constant.loadType;//加载方式
        me.callParent(arguments);
    },
    //导出
    onExportClick: function(){
    	var me = this;
        var store = me.getStore();
        var params=store.proxy.extraParams;
        var href=me.store.classDetailsUrl + "?page=-1";
        for(var param in params){
        	if(params[param] === undefined){
        		href+="&"+param+"=";
        	}else{
        		href+="&"+param+"="+params[param];
        	}
        }
        href = encodeURI(href);
        var atag = Ext.get("exportResume");
        atag.set({
            "href": href
        });
        atag.dom.click();
    },
    /*
    //导出
    onConfigureClick: function(exportUrl){
    	var me = this;
        //查询条件 
        var form = this.down('searchform');
		var baseForm = form.getForm();
        // 转移字符格式
        var searchQuestionnaireName = encodeURIComponent(baseForm.findField("searchQuestionnaireName").getValue());
        var searchUserName= encodeURIComponent(baseForm.findField("searchUserName").getValue());
		var classnamePeriodType = baseForm.findField("classnamePeriodType").getValue() == null ? "" : baseForm.findField("classnamePeriodType").getValue();
		var startTime = baseForm.findField("searchStartTime").getValue() == null ? "" : baseForm.findField("searchStartTime").getValue();
		var searchStartTime = Ext.Date.format(startTime,'Y-m-d');
		var endTime = baseForm.findField("searchEndTime").getValue() == null ? "" : baseForm.findField("searchEndTime").getValue();
		var searchEndTime = Ext.Date.format(endTime,'Y-m-d');

        //列表某个排序字段的相关信息
        var sortString = '';
        var sort = new Array();
        sort.push(this.store.sorters.items);
        if(sort!= null && sort!=""){
			var property = sort[0][0].property; //列表字段名
			var direction = sort[0][0].direction; //列表字段排序方式
			sortString = '[{"property":"'+property+'","direction":"'+ direction +'"}]';
		}
        var sortStrings = !Ext.isEmpty(sort)? sortString : "";
        //选中数据内容
        var records = me.getSelectionModel().getSelection();
        var paperIds = new Array();
        Ext.Array.each(records, function(name, index){
        	paperIds.push(name.get("paperId"));
        });
        
        var atag = Ext.get("exportResume");
        atag.set({
            "href": exportUrl+ '?paperIds='+ paperIds + 
            					'&searchQuestionnaireName=' + searchQuestionnaireName +
    							'&searchUserName=' + searchUserName +
    							'&classnamePeriodType=' + classnamePeriodType +
    							'&searchStartTime='+ searchStartTime +
    							'&searchEndTime=' + searchEndTime
        });
        atag.dom.click();
    },
    */
    listeners: {
    	selectionchange: function(selModel, selected){
            //this.down('#' + this.oldId + "Export").setDisabled(selected.length === 0);
        },
    	viewready: function(){
    		var me = this;
	    	//导出按钮集合
    		/*
	    	var exportMenu = Ext.create('Ext.menu.Menu', {
	            items: [{
	                text: '培训班评估详情',
	        		iconCls: 'classDetailsIco',
	                listeners: {
	                	click: function(btn){
	                    	me.onConfigureClick(me.store.classDetailsUrl);
	                	}
	                }
	            }, {
	                text: '培训班评估分',
	        		iconCls: 'scoreIco',
	                listeners: {
	                	click: function(btn){
	                    	me.onConfigureClick(me.store.classScoreUrl);
	                	}
	                }
	            }, {
	                text: '主观题评估详情',
	        		iconCls: 'reportCardIco',
	                listeners: {
	                	click: function(btn){
	                    	me.onConfigureClick(me.store.subjectiveDetailsUrl);
	                	}
	                }
	            }]
	        });
	        */
    		me.addDocked([{
    			dock: 'top',
    			xtype: "searchform",
    			columnCount: 3,
    			fieldDefaults: {
    				labelAlign: 'right',
    				labelWidth: 90
    			},
    			items: [{
    				xtype: "textfield",
    				fieldLabel: '培训班编号',
    				name: "searchClassNum",
    				maxLength: "50",
    				emptyText: "请输入培训班编号"
    			}, {
    				xtype: 'defaultDate',
    				fieldLabel: '评估开始时间',
    				name: 'searchAssessStartTime',
    				id: 'searchAssessStartTimebw',
    				vtype: 'startLessEndDate',
    				startLessEndDate: {
    					targetCmpId: 'searchAssessEndTimebw',
    					isStart: true
    				},
    				emptyText: "请输入评估开始时间",
    				labelWidth: 90
    			}, {
    				xtype: 'defaultDate',
    				fieldLabel: '评估结束时间',
    				name: 'searchAssessEndTime',
    				id: 'searchAssessEndTimebw',
    				vtype: 'startLessEndDate',
    				vtypeText: '结束时间不能早于开始时间！',
    				startLessEndDate: {
    					targetCmpId: 'searchAssessStartTimebw',
    					isStart: false
    				},
    				emptyText: "请输入评估结束时间",
    				labelWidth: 90
    			}, {
    				xtype: "textfield",
    				fieldLabel: '培训班问卷名称',
    				name: "searchClassName",
    				maxLength: "20",
    				emptyText: "请输入培训班问卷名称",
    				labelWidth: 90
    			}, {
    				xtype: 'defaultDate',
    				fieldLabel: '开班时间',
    				name: 'searchBeginDate',
    				id: 'searchEvaluationClassSDbw',
    				vtype: 'startLessEndDate',
    				startLessEndDate: {
    					targetCmpId: 'searchEvaluationClassEDbw',
    					isStart: true
    				},
    				emptyText: "请输入开班时间",
    				labelWidth: 90
    			}, {
    				xtype: 'defaultDate',
    				fieldLabel: '结业时间',
    				name: 'searchEndDate',
    				id: 'searchEvaluationClassEDbw',
    				vtype: 'startLessEndDate',
    				vtypeText: '结业时间不能早于开班时间！',
    				startLessEndDate: {
    					targetCmpId: 'searchEvaluationClassSDbw',
    					isStart: false
    				},
    				emptyText: "请输入结业时间",
    				labelWidth: 90
    			}, {
    				xtype: "textfield",
    				fieldLabel: '承办部委',
    				name: "searchMinistrieName",
    				emptyText: "请输入承办部委"
    			}],
    			grid: this
    		}, {
                xtype: 'toolbar',
                dock: 'top',
                displayInfo: true,
                items: [{
                    text: '导出',
                    iconCls: 'deriveIco',
                    itemId: this.oldId + "Export",
                    disabled: false,
                    scope: this,
                    handler: this.onExportClick
                }]
            }]);
            var store = this.store;
            var params = store.proxy.extraParams;
            var newParams = {};
            Ext.apply(params, newParams);
            store.isLoad = true;
            store.load();
    		// 触发权限过滤事件
    		this.fireEvent("permission", this);
    	}
    }
});
